import {API} from './config';
import CustomRequest from '@/utils/Request'

/* 
* 添加
*/
const add = async (params = {}) => {
  return CustomRequest({
    api: API.adminAdd,
    method: 'post',
    params
  })
}

/* 
* 更新
*/
const update = async (params = {}) => {
  return CustomRequest({
    api: API.adminUpdate,
    method: 'post',
    params
  })
}

/* 
* 删除
*/
const del = async (id) => {
  return CustomRequest({
    api: API.adminDel + `/${id}`,
    params: {id}
  })
}

/* 
* 分页
*/
const pageList = async (params = {}) => {
  return CustomRequest({
    api: API.adminPage,
    method: 'post',
    params
  })
}

/* 
* 详情
*/
const detail = async (id) => {
  return CustomRequest({
    api: API.adminDetail + `/${id}`
  })
}

/* 
* 更新管理员状态
*/
const updateStatus = async (id, status) => {
  return CustomRequest({
    api: API.adminUpdateStatus + `/${id}/${status}`,
    method: 'post'
  })
}

/* 
* 获取角色列表
*/
const resetPassword = async (id) => {
  return CustomRequest({
    api: API.adminResetPassword + `/${id}`,
    method: 'post'
  })
}

export {
  add,
  update,
  del,
  pageList,
  detail,
  updateStatus,
  resetPassword
}